<?php
class CartController extends Core_Controller_Action {
	protected $_cart;
	protected $_style = array ('/styles/basic.css', '/styles/catalog.css', '/styles/busket.css', '/styles/other.css' );
	
	public function preDispatch() {
		$this->_cart = $this->_api->Cart;
	}
	
	public function indexAction() {
		if ($this->_cart->getAmount () === 0)
			$this->_redirect ( $this->view->url ( array (), null, true ) );
		$this->view->products = $this->_cart->getProducts ();
		$this->view->amount = $this->_cart->getAmount ();
		$this->view->account = $this->_cart->getAccount ();
	}
	
	public function ordersummaryAction() {
		$this->_style = array('/styles/other.css');
		if ($this->_cart->getAmount () === 0)
			$this->_redirect ( $this->view->url ( array (), null, true ) );
		$this->view->products = $this->_cart->getProducts ();
		$this->view->amount = $this->_cart->getAmount ();
		$this->view->account = $this->_cart->getAccount ();
//		$this->view->fulldate = date ( 'd.m.Y' );
		
		$userName = Zend_Registry::get ( 'Core_User' )->getLogin ();
		
//		$this->Mail ( $userName );
	
		//		$api = Zend_Registry::get('api');
	//		$api->Cart->clear();
	}
	
	private function Mail($userName) {
		$a = "firmanigorromanovuch@gmail.com";
		$orderSummary = "afwfaf"; //$this->view->render( $this->_config->controls->ordersummaryPreorder );
		$mail = new Zend_Mail ( 'UTF-8', Zend_Mime::ENCODING_8BIT );
		//     	$mail->setBodyText();
		$mail->setBodyHtml ( $orderSummary );
		$mail->setFrom ( 'firmanik08@mail.ru', 'admin' );
		$mail->addTo ( $a, $userName );
		$mail->setSubject ( 'sda' );
	
		//     	var_dump($mail);
	//     	$mail->send();
	}
}